<script type="text/javascript">
var qty = 0;
var amount = 0;
function hitungTotal(totalcont,val){
	//alert(totalcont.id);
	totalcont.value = (this.qty * this.amount);
}
function setQty(qty){
	this.qty = qty.value;
}
function setAmount(amt){
	this.amount = amt.value;
}

function onlyNumbers(evt) 
{
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
		//status = "This field accepts numbers only."
		alert("Harus di Isi Angka");
		return false
	}
	//status = ""
	return true 	
}
</script>
<form method="post" name="frmSearch" action="<?php echo site_url('returpembeliancontroller');?>">
    <table width="100%" cellpadding="3" cellspacing="0" border="1">
        <tr>
            <td width="173"><strong>Pilih Search</strong></td>
            <td width="19" align="center"><strong>:</strong></td>
            <td width="778" colspan="3">
                <select name="kdview">
                    <option value="0">Pilih</option>
                    <option value="1">Kode Retur</option>
                    <option value="2">Nama Supplier</option>
                    <option value="3">Nama Barang</option>
                </select> &nbsp;|&nbsp;<input type="text"  name="namaview" id="namaview" size="50" />
            </td>
		</tr>
        <tr align="center">
        	<td colspan="5" height="25"><input type="submit" name="btnview" value="Search"></td>
    	</tr>
    </table>
</form>
<br />
<form method="post" name="frmSave" action="<?php echo site_url('returpembeliancontroller/tambahreturpembelian');?>">
    <table width="100%" cellpadding="3" cellspacing="0" border="1">
    	<tr style="background-color:#FFF; color:#000000;" align="center">
        	<td colspan="3" height="25"><strong>INPUT RETUR PEMBELIAN</strong></td>
    	</tr>
        <tr >
        	<td colspan="3" height="25">&nbsp;</td>
    	</tr>
        <tr>
            <td width="178"><strong>Kode Retur</strong></td>
            <td width="28" align="center"><strong>:</strong></td>
            <td width="764" colspan="3"><input type="text"  name="kdretur" id="kdretur" maxlength="12" size="25" value="{kodereturno}" readonly="readonly" /></td>
        </tr>
        <tr>
            <td width="178"><strong>Nama supplier</strong></td>
            <td width="28" align="center"><strong>:</strong></td>
            <td ><select name="kdsupp">
                    <?php 
						$count = count($mstrsupp);
                    	foreach($mstrsupp as $comboInd)
						{
                    ?>
                    	<option value="<?php echo $comboInd->Kodesupplier?>"><?php echo $comboInd->suppliername;?></option>
                    <?php }?>
                </select></td>
        </tr>
        <tr>
            <td width="178"><strong>Keterangan</strong></td>
            <td width="28" align="center"><strong>:</strong></td>
            <td ><input type="text"  name="keterangan" id="keterangan" size="100" maxlength="100"/></td>
        </tr>       
	</table>
    <input type="button" id="btnAddingDiv" name="btnAddingDiv" value="Add Detail" />
    <br /><br />
    <div id="divrows">
    <div><table width="100%" cellpadding="3" cellspacing="0" border="1"><tr style="background-color:#FFF; color:#000000;" align="center"><td colspan="3" height="25"><strong>Detail Retur Pembelian</strong></td></tr><tr><td width="131"><strong>Nama Barang</strong></td><td width="23" align="center"><strong>:</strong></td><td width="760" ><select name="kdbarang[]"><?php $count = count($masterbarang);foreach($masterbarang as $comboInd){?><option value="<?php echo $comboInd->KodeDetailBarang?>"><?php echo $comboInd->Productname;?></option><?php }?></select></td></tr><tr><td width="131"><strong>Harga Barang</strong></td><td width="23" align="center"><strong>:</strong></td><td ><input type="text" name="hrgbarang[]" id="hrgbarang[]" size="50" maxlength="11" onkeyup="javascript:setAmount(this);" onkeypress="return onlyNumbers(event);"/></td></tr><tr><td width="131"><strong>Quantity</strong></td><td width="23" align="center"><strong>:</strong></td><td ><input type="text" name="qty[]" id="qty[]" size="50" maxlength="4" onkeyup="javascript:setQty(this);" onkeypress="return onlyNumbers(event);"/></td></tr><tr><td width="131"><strong>Discount</strong></td><td width="23" align="center"><strong>:</strong></td><td ><input type="text"  name="distcoun[]" id="distcoun[]" size="50" maxlength="4"/></td></tr><tr><td width="131"><strong>Jumlah Harga</strong></td><td width="23" align="center"><strong>:</strong></td><td ><input type="text" name="jmlhhrg[]" id="jmlhhrg[]" class="flat-textbox" size="15" maxlength="11" onmousedown="javascript:hitungTotal(this,0);"/></td></tr></table></div><br/>
    </div>
    <table border="1" cellpadding="3" cellspacing="0" width="100%" style=" border-collapse: collapse;" class="record" bordercolor="#000000">
    	<tr class="cellDefault">
			<td colspan="11" align="center"><input type="submit" name="btnSave" value="Simpan"> &nbsp;|&nbsp; <input type="button" name="btnClose" value="Back" class="btn" onclick="javascript:window.location='<?php echo site_url('menuhomecontroller'); ?>';" /></td>
		</tr>
    </table>   
</form>
<br />
<br />
<div class="cleaner_h10"></div>
<table border="1" cellpadding="3" cellspacing="0" width="100%" style=" border-collapse: collapse;" class="record" bordercolor="#CCCCCC">
    <tr style="background-color:#FFF; color:#000000;" align="center">
        <td colspan="11" height="25"><strong>LIST RETUR PEMBELIAN</strong></td>
    </tr>
    <tr style="background-color:#333; color:#FFF;" align="center">
    	<td>Kode Retur</td>
        <td>Tanggal Retur</td>
        <td>Nama Supplier</td>
        <td>Nama Barang</td>
        <td>Harga Barang</td>
        <td>Quantity</td>
        <td>Discount</td>
        <td>Amount</td>
        <td>Keterangan</td>
        <td>&nbsp;</td>
    </tr>
	<?php if(count($transretur)>0){ ?>
        {transretur}
            <tr class="cellDefault">
                <td align="center">{ReturnNo}</td>
                <td align="center">{DateReturn}</td>
                <td align="center">{suppliername}</td>
                <td align="center">{Productname}</td>
                <td align="center">{HargaBarang}</td>
                <td align="center">{QTY}</td>
                <td align="center">{Discount}</td>
                <td align="center">{Amount}</td>
                <td align="center">{Keterangan}</td>
                <td align="center">
                	<button onclick="javascript:window.location='<?php echo site_url('returpembeliancontroller/cetak_faktur');?>/{ReturnNo}/{IDdetail}';" id="cetak">Cetak</button>
                	&nbsp;|&nbsp;
                	<button onclick="javascript:window.location='<?php echo site_url('returpembeliancontroller/ubahreturpembelian');?>/{ReturnNo}/{IDdetail}';" id="edit">Edit</button>
                <?php
                if($this->session->userdata('grade') == 0)
				{
				?>
                	&nbsp;|&nbsp;
                	<button id="hapus" onclick="javascript:window.location='<?php echo site_url('returpembeliancontroller/deletereturpembelian');?>/{ReturnNo}/{IDdetail}';">Hapus</button>
				<?php } ?>
                </td>
            </tr>
        {/transretur}
    <?php } else{
            echo "<tr>";
            echo "<td colspan='9' style='text-align:center;color:red;'>No Data To Display</td>";
            echo "</tr>";
    } ?>
    <?php if(!empty($message))?>{message}
</table>
<?php echo $links; ?>